﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.Windows.Controls.DataVisualization.Charting;
using System.ComponentModel;

namespace PistonWheel
{
    /// <summary>
    /// Interaction logic for Charts.xaml
    /// </summary>
    public partial class Charts : Window
    {
        public ObservableCollection<Wheel> WheelData { get; set; }
        public ObservableCollection<Rod> RodData { get; set; }
        public ObservableCollection<Piston> PistonData { get; set; }

        public Charts()
        {
            InitializeComponent();
        }

        public void AddWheelSpeedLineSeries()
        {
           // string title = "title";
            LineSeries ls1 = new LineSeries();
            ls1.SetBinding( LineSeries.ItemsSourceProperty, new System.Windows.Data.Binding() );
            ls1.ItemsSource = this.WheelData;
            ls1.Title = "Ф(t)";
            ls1.DependentValueBinding = new System.Windows.Data.Binding( "Angle" );
            ls1.IndependentValueBinding = new System.Windows.Data.Binding( "Time" );
            this.wheelChartPosition.Series.Add( ls1 );

            LineSeries ls2 = new LineSeries();
            ls2.SetBinding( LineSeries.ItemsSourceProperty, new System.Windows.Data.Binding() );
            ls2.ItemsSource = this.WheelData;
            ls2.Title = "ω(t)";
            ls2.DependentValueBinding = new System.Windows.Data.Binding( "AngularVelocity" );
            ls2.IndependentValueBinding = new System.Windows.Data.Binding( "Time" );
            this.wheelChartVelocity.Series.Add( ls2 );
        }

        public void AddRodDataLineSeries()
        {
            LineSeries ls1 = new LineSeries();
            ls1.SetBinding( LineSeries.ItemsSourceProperty, new System.Windows.Data.Binding() );
            ls1.ItemsSource = this.RodData;
            ls1.Title = "ψ(t)";
            ls1.DependentValueBinding = new System.Windows.Data.Binding( "Angle" );
            ls1.IndependentValueBinding = new System.Windows.Data.Binding( "Time" );
            this.rodChartPosition.Series.Add( ls1 );

            LineSeries ls2 = new LineSeries();
            ls2.SetBinding( LineSeries.ItemsSourceProperty, new System.Windows.Data.Binding() );
            ls2.ItemsSource = this.RodData;
            ls2.Title = "ω(t)";
            ls2.DependentValueBinding = new System.Windows.Data.Binding( "AngularVelocity" );
            ls2.IndependentValueBinding = new System.Windows.Data.Binding( "Time" );
            this.rodChartVelocity.Series.Add( ls2 );
        }

        public void AddPistonDataLineSeries()
        {
            LineSeries ls1 = new LineSeries();
            ls1.SetBinding( LineSeries.ItemsSourceProperty, new System.Windows.Data.Binding() );
            ls1.ItemsSource = this.PistonData;
            ls1.Title = "y(t)";
            ls1.DependentValueBinding = new System.Windows.Data.Binding( "YPos" );
            ls1.IndependentValueBinding = new System.Windows.Data.Binding( "Time" );
            this.pistonChartPosition.Series.Add( ls1 );

            LineSeries ls2 = new LineSeries();
            ls2.SetBinding( LineSeries.ItemsSourceProperty, new System.Windows.Data.Binding() );
            ls2.ItemsSource = this.PistonData;
            ls2.Title = "v(t)";
            ls2.DependentValueBinding = new Binding( "Speed" );
            ls2.IndependentValueBinding = new Binding( "Time" );
            this.pistonChartVelocity.Series.Add( ls2 );
        }
    }
}
